// 登陆之前查看是否有token

if (!localStorage.getItem('token')) {
    location.href = '/login.html';
}
$(function() {
    $.ajaxPrefilter(function(options) {
        // console.log(options);
        options.url = 'http://www.liulongbin.top:3007' + options.url;
        options.headers = {
            Authorization: localStorage.getItem('token'),
        };
        options.beforeSend = function() {
            NProgress.start()
        };
        options.complete = function(xhr) {
            NProgress.done()
            console.log(xhr);
            if (xhr.responseJSON.status === 1 && xhr.responseJSON.message === '身份认证失败！') {
                // 移除假的token 并且返回login页面
                localStorage.removeItem('token');
                location.href = '/login.html';
            }

        }
    })
})